//服务器监控-CPU使用率
export function cpuEchart(data) {
	return {
		title: {
			text: '服务器CPU使用率',
			left: 'center',
			top: 20
		},
		tooltip: {
			trigger: 'axis',
			formatter: function(params) {
				params = params[0];
				var date = params.name;
				return `${date}<br/> 使用率 : ${params.value[1]}%`;
			},
			axisPointer: {
				animation: false
			}
		},
		xAxis: {
			type: 'time',
			name: '时间',
			splitLine: {
				show: false
			}
		},
		yAxis: {
			type: 'value',
			name: 'CPU使用率 (%)',
			boundaryGap: [0, '100%'],
			splitLine: {
				show: false
			}
		},
		series: [{
			name: 'CPU使用率',
			type: 'line',
			showSymbol: false,
			hoverAnimation: false,
			data: data
		}]
	}
}

//服务器监控-内存占比
export function memEchart(data) {
	return {
		title: {
			text: '服务器内存占比',
			left: 'center',
			top: 20
		},
		tooltip: {
			trigger: 'item',
			formatter: "{b}：{c} M <br/>占总内存：{d}%"
		},
		series: [{
			name: '服务器内存占比',
			type: 'pie',
			label: {
				normal: {
					formatter: '{b}: {d}%'
				}
			},
			radius: '55%',
			center: ['50%', '60%'],
			data: data,
			itemStyle: {
				emphasis: {
					shadowBlur: 10,
					shadowOffsetX: 0,
					shadowColor: 'rgba(0, 0, 0, 0.5)'
				}
			}
		}]
	}
}

//Redis队列-内存实时占用情况
export function redisMemEchart(data) {
	return {
		title: {
			text: 'Redis 内存实时占用情况：',
			left: 'center',
			top: 20
		},
		tooltip: {
			trigger: 'axis',
			formatter: function(params) {
				params = params[0];
				var date = params.name;
				return `${date}<br/> 使用率 : ${params.value[1]}KB`;
			},
			axisPointer: {
				animation: false
			}
		},
		xAxis: {
			type: 'time',
			name: '时间',
			splitLine: {
				show: false
			}
		},
		yAxis: {
			type: 'value',
			name: '大小 (KB)',
			boundaryGap: [0, '100%'],
			splitLine: {
				show: false
			}
		},
		series: [{
			name: 'CPU使用率',
			type: 'line',
			showSymbol: false,
			hoverAnimation: false,
			data: data
		}]
	}
}

//Redis队列-key的实时数量
export function redisKeyEchart(timeData, data) {
	return {
		title: {
			text: 'key的实时数量',
			left: 'center',
			top: 20
		},
		tooltip: {
			trigger: 'axis'
		},
		xAxis: {
			name: '时间',
			type: 'category',
			boundaryGap: false,
			data: timeData
		},
		yAxis: {
			name: '数量',
			type: 'value'
		},
		series: data
	}
}